<?php
define("TOKEN", "cjjcjj");
$wechatObj = new wechatCallbackapiTest();
$wechatObj->valid();
class wechatCallbackapiTest
{
    public function valid()
    {
        $echoStr = $_GET["echostr"];        //����ַ���
        
        if($this->checkSignature()){
             ob_clean();
            echo $echoStr;
            exit;
        }
    }
    private function checkSignature()
    {
        $signature = $_GET["signature"];    //΢�ż���ǩ��
        $timestamp = $_GET["timestamp"];    //ʱ���
        $nonce = $_GET["nonce"];            //�����
        $token = TOKEN;
        $tmpArr = array($token, $timestamp, $nonce);
        sort($tmpArr);      //�����ֵ�������
        //sha1���ܺ���ǩ���Ա�
        if( sha1(implode($tmpArr)) == $signature ){
            return true;
        }else{
            return false;
        }
    }
}
?>